<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ page import="net.sapfree.core.util.DateUtility"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="login,regist first">
<meta http-equiv="description" content="This is login page">

<title>我的飞客</title>
<link href="<%=path%>/include/styleBase/css/fontStyle.css" rel="stylesheet"></link>
<link href="<%=path%>/include/styleBase/css/formStyle.css" rel="stylesheet"></link>
<link href="<%=path%>/include/DatePicker/skin/formStyle.css" rel="stylesheet"></link>

<script type="text/javascript" src="<%=path%>/include/js/jquery.js"></script>
<script type="text/javascript" src="<%=path%>/include/js/style.js"></script>
<script type="text/javascript" src="<%=path%>/include/DatePicker/WdatePicker.js"></script>
 
<script type="text/javascript" src="<%=path%>/include/KindEditor/kindeditor.js"></script>


<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style>
<script>


function saveBlog(){
	//alert(window.parent.document.frm.action);
	content = KE.util.getPureData("editorContent")
	htmlcontent = KE.html("editorContent");
	
	document.getElementById("CONTENT").value=content;
	document.getElementById("HTMLCONTENT").value=htmlcontent;
	
	document.frm.action="<%=path%>/article/articlelist?method=saveNewBlog";
	
	document.frm.submit();
}


function getArticleTitle(){
	return $("#ARTICLE_AI_TITLE").val();
}

function getArticlePublishTime(){
	return '<%=DateUtility.getCurrentDate()%>'+$("#curtime").val();
}

function getArticleTagInfo(){
	return $("#TAGINFO").val();
}


function preViewBlog(){
  //  alert(htmlcontent = KE.html("editorContent"));
	window.open("<%=path%>/jsp/article/preViewBlog.jsp");
}


$(document).ready(function(){
    //富文本编辑器
    KE.show({
		id : 'editorContent',
		resizeMode : 1,
		allowUpload : true,
		imageUploadJson : '<%=path%>/servlet/FileUploadManagerServlet?method=saveImageOfArticle',
		afterCreate : function(id) {},
		items : ["source","|","fullscreen","undo","redo","print","cut","copy","paste","plainpaste",
"wordpaste","|","justifyleft","justifycenter","justifyright","justifyfull","insertorderedlist","insertunorderedlist","indent","outdent","subscript","superscript","|","selectall","-","title","fontname","fontsize","|","textcolor","bgcolor","bold","italic","underline","strikethrough","removeformat","|","image","flash","media","advtable","hr","emoticons","link","unlink","|","about"]
	});
	
});


function _showVote(){
	if(document.frm.ISVOTE.checked){
		$("#votearea").show();
	}else{
		$("#votearea").hide();
	}
}

var optcount=5;
function addvoteOpt(){
	
	var optHtml='<div><span style=\"width:80px;text-align:right;\">选项'+optcount+'</span>'+
				'  <input type=\"text\" name=\"OPTIONTITLE\" style=\"font-size:18px; width:400px;\"></div>';
	$("#voteOptSpan").append(optHtml);
	optcount=optcount+1;
}

			
</script>

</head>
<body style="text-align:center;">


<form name="frm" method="post">

<input style="width:100%;display:none;" type="text" id="CONTENT" name="CONTENT" value=""/>                  
<input style="width:100%;display:none;" type="text" id="HTMLCONTENT" name="HTMLCONTENT" value=""/>                  


<div style="text-align:left;width:80%;">

<div style="margin-top:20px;">
      <table>
          <tr>
              <td class="tdTitle">
                  标题：
              </td>
              <td>
                  <input class="inputTxt" type="text" id="ARTICLE_AI_TITLE" name="ARTICLE_AI_TITLE" value="" style="width:600px;"/>
              </td>
              <td>
              	  <div style="margin-left:20px;">时间：<%=DateUtility.getCurrentDate()%>
              	  		<input class="inputTxt" style="width:80px;" type="text" id="curdate" name="curdate" value="<%=DateUtility.getCurrentDate()%>"/>
              	 		<input class="inputTxt" style="width:80px;" type="text" id="curtime" name="curtime" value="<%=DateUtility.getCurrentTime()%>"/>
              	  </div>
              </td>
          </tr>
      </table>
</div>


<div style="margin-top:20px;">
	<textarea class=""  id ="editorContent" name="editorContent" minlength="20" required error="正文内容不能为空或过于简洁！" label="申请正文" style="width:98%;height:395px;visibility:hidden;word-wrap:break-word;word-break:break-all;" ></textarea>
</div>


<div style="margin-top:10px;">
	<input name="ARTICLE_AI_ISDISCUSS" type="radio" value="1" checked>允许所有人评论&nbsp;&nbsp;<input name="ARTICLE_AI_ISDISCUSS" type="radio" value="0">&nbsp;不允许评论
</div>


<div style="margin-top:5px;">
     标签：<input class="inputTxt" type="text" id="TAGINFO" name="TAGINFO" value="" style="width:600px;"/>
</div>


<div class="orangeBold14" style="margin-top:5px;" >
	<input type="checkbox" id="ISVOTE" name="ISVOTE" onClick="_showVote()" value="1">&nbsp;插入投票
</div>


<div id="votearea" style="background-color:#EEEEEE;border:1px solid #AAAAAA;padding:10px;width:98%;display:none;">
	<div>
		<span style="width:80px;text-align:right;">投票主题：</span><span><input type="text" name="VOTE_VI_TITLE" style="font-size:18px; width:400px;"></span>
		<span class="blackNormal14" style="margin-left:25px;">投票类型：<input type="radio" name="VOTE_VI_TYPE" checked value="1">单选 <input type="radio" name="VOTE_VI_TYPE" value="2">多选</span>
	</div>
	
	<div style="margin-top:10px;">
		<span style="width:80px;text-align:right;">投票选项：</span>
		<span class="greyNormal12">每行填写一个选项，最多可以填写10个选项。</span>
	</div>
	
	<div>
		<span id="voteOptSpan" class="greyNormal12" style="width:490px;">
			<div>
				<span style="width:80px;text-align:right;">选项1</span>
				<input type="text" name="OPTIONTITLE" style="font-size:18px; width:400px;">
			</div>
			<div>
				<span style="width:80px;text-align:right;">选项2</span>
				<input type="text" name="OPTIONTITLE" style="font-size:18px; width:400px;">
			</div>
			<div>
				<span style="width:80px;text-align:right;">选项3</span>
				<input type="text" name="OPTIONTITLE" style="font-size:18px; width:400px;">
			</div>
			<div>
				<span style="width:80px;text-align:right;">选项4</span>
				<input type="text" name="OPTIONTITLE" style="font-size:18px; width:400px;">
			</div>
		</span>
		<span style="vertical-align:top;width:30%;padding-left:25px;">
			<div >
				截止日期
				<input type="text" size="25" id="VOTE_VI_CLOSEDATE" name="VOTE_VI_CLOSEDATE" readonly="readonly" class="textInput" value=""
									onfocus="WdatePicker({skin:'blue'})" style="width: 160px;"
									label="开始日期"  onchange='$(this).val($.trim($(this).val()))' minApplyDate='%y-%M-%d %H:%m' />
			</div>
			
			<div style="margin-top:5px;">
				<span class="blackNormal14">开放式投票<input type="checkbox" name="VOTE_VI_ISOPEN" value="1"></span>
			</div>
			
			<div>
				<span class="greyNormal12"><img src="../images/lightbulb.png" align="absmiddle">&nbsp;选择开放式投票，将允许用户添加投票选项。</span>
			</div>
		</span>
	</div>
	<div><span class="orangeNormal12" style="cursor:hand;margin-left:85px;" onclick="addvoteOpt();">+ 添加选项</span></div>
</div>






<table border="0" cellpadding="0" cellspacing="0" width="310" style="margin-top:20px;" align="center">
	<tr>
    	<td width="70">
        <table border="0" cellpadding="0" cellspacing="0" width="60" height="25">
            <tr>
              <td width="60" bgcolor="f6891f" align="center" style="cursor:hand;"><span style="color:#FFFFFF; font-weight:bold; font-size:14px;" onClick="saveBlog();">发布</span></td>
            </tr>
        </table>
        </td>
        <td width="70">
        <table border="0" cellpadding="0" cellspacing="0" width="60" height="25">
            <tr>
              <td width="60" bgcolor="f6891f" align="center" style="cursor:hand;"><span style="color:#FFFFFF; font-weight:bold; font-size:14px;" onClick="preViewBlog();">预览</span></td>
            </tr>
        </table>
        </td>
        <td width="170">
        <table border="0" cellpadding="0" cellspacing="0" width="120" height="25">
            <tr>
              <td width="120" bgcolor="f6891f" align="center" style="cursor:hand;"><span style="color:#FFFFFF; font-weight:bold; font-size:14px;">保存到草稿箱</span></td>
            </tr>
        </table>
        </td>
    </tr>
</table>

</div>

</form>
</body>
</html>